/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Telas;

import Conexao.ConectaBD;
import java.awt.Toolkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;

/**
 *
 * @author Thalyson
 */
public class Tela_GerOSTecnico extends javax.swing.JFrame {

    Connection conecta;
    PreparedStatement pst;
    ResultSet rs;
    
    public Tela_GerOSTecnico() throws ClassNotFoundException {
        initComponents();
        setSize(1283, 653);
        setLocationRelativeTo(null);
        conecta = ConectaBD.conectabd();
        listarOS();
        Icon();
        selecionaTecnico();
    }

//<----------------------------------------------------------------------------------------------------------------------------------------->    

    private void Icon(){
    
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("assistec_icon.png")));
        
    }    
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void listarOS() {
        String sql = "Select *from os order by id Desc";
        try {
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();
            jt_os.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void pesquisarCliente() {
        String sql = "Select *from os where Nome like ?";

        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_pesquisar.getText() + "%");
            rs = pst.executeQuery();
            jt_os.setModel(DbUtils.resultSetToTableModel(rs));
        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void mostraItens() throws ClassNotFoundException {

        int seleciona = jt_os.getSelectedRow();
        tf_id.setText(jt_os.getModel().getValueAt(seleciona, 0).toString());
        tf_nome.setText(jt_os.getModel().getValueAt(seleciona, 1).toString());
        tf_endereco.setText(jt_os.getModel().getValueAt(seleciona, 2).toString());
        tf_numero.setText(jt_os.getModel().getValueAt(seleciona, 3).toString());
        jf_telefone.setText(jt_os.getModel().getValueAt(seleciona, 4).toString());
        tf_produto.setText(jt_os.getModel().getValueAt(seleciona, 5).toString());
        tf_marcamodelo.setText(jt_os.getModel().getValueAt(seleciona, 6).toString());
        tf_nserie.setText(jt_os.getModel().getValueAt(seleciona, 7).toString());
        cb_acessorios.setSelectedItem(jt_os.getModel().getValueAt(seleciona, 8).toString());
        jt_acessorios.setText(jt_os.getModel().getValueAt(seleciona, 9).toString());
        cb_tecnico.setSelectedItem(jt_os.getModel().getValueAt(seleciona, 10).toString());
        jf_entrada.setText(jt_os.getModel().getValueAt(seleciona, 11).toString());
        jf_saida.setText(jt_os.getModel().getValueAt(seleciona, 12).toString());
        cb_situacao.setSelectedItem(jt_os.getModel().getValueAt(seleciona, 13).toString());
        cb_status.setSelectedItem(jt_os.getModel().getValueAt(seleciona, 14).toString());
        tf_pecas.setText(jt_os.getModel().getValueAt(seleciona, 15).toString());
        tf_maodeobra.setText(jt_os.getModel().getValueAt(seleciona, 16).toString());
        tf_total.setText(jt_os.getModel().getValueAt(seleciona, 17).toString());
        jt_ordemservico.setText(jt_os.getModel().getValueAt(seleciona, 18).toString());
        jt_processos.setText(jt_os.getModel().getValueAt(seleciona, 19).toString());
    }
    
//<----------------------------------------------------------------------------------------------------------------------------------------->    

    public void editarOS() {
        String sql = "Update os set Nome = ?,Endereço = ?,Numero = ?,Telefone = ?,Produto = ?,Marca_Modelo = ?,NSerie = ?,Acessorios = ?,Acessorios_Produto = ?,Tecnico = ?,Entrada = ?,Saida = ?,Situaçao = ?,Status = ?,Total_Peças = ?,Total_MaoDeObra = ?,Valor_Total = ?,OS = ?,Processos = ? where id = ? ";
        
        if(cb_situacao.getSelectedItem().equals("SITUAÇÃO ATUAL")){
        JOptionPane.showMessageDialog(null, "Campo Situação Atual é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(cb_situacao.getSelectedItem().equals("EM ESPERA")){
        JOptionPane.showMessageDialog(null, "Campo Situação Atual não pode constar como Em Espera", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_pecas.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo R$ Peças é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_maodeobra.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo R$ Mão De Obra é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        if(tf_total.getText().equals("")){
        JOptionPane.showMessageDialog(null, "Campo R$ Total é Obrigatório", "Aviso", JOptionPane.WARNING_MESSAGE);
        return;
        }
        
        
        try {
            pst = conecta.prepareStatement(sql);
            pst.setString(1, tf_nome.getText());
            pst.setString(2, tf_endereco.getText());
            pst.setString(3, tf_numero.getText());
            pst.setString(4, jf_telefone.getText());
            pst.setString(5, tf_produto.getText());
            pst.setString(6, tf_marcamodelo.getText());
            pst.setString(7, tf_nserie.getText());
            pst.setString(8, cb_acessorios.getSelectedItem().toString());
            pst.setString(9, jt_acessorios.getText());
            pst.setString(10, cb_tecnico.getSelectedItem().toString());
            pst.setString(11, jf_entrada.getText());
            pst.setString(12, jf_saida.getText());
            pst.setString(13, cb_situacao.getSelectedItem().toString());
            pst.setString(14, cb_status.getSelectedItem().toString());
            pst.setString(15, tf_pecas.getText());
            pst.setString(16, tf_maodeobra.getText());
            pst.setString(17, tf_total.getText());
            pst.setString(18, jt_ordemservico.getText());
            pst.setString(19, jt_processos.getText());
            pst.setInt(20, Integer.parseInt(tf_id.getText()));
            pst.executeUpdate();
            JOptionPane.showMessageDialog(null, "O.S. Atualizada com Sucesso");
            listarOS();

        } catch (SQLException error) {
            JOptionPane.showMessageDialog(null, error);
        }
    }

//<----------------------------------------------------------------------------------------------------------------------------------------->    
    private void selecionaTecnico() {

        try {
                
            String sql = "select * from funcionario";
            pst = conecta.prepareStatement(sql);
            rs = pst.executeQuery();                
            while (rs.next()) {
                String NomeProduto = rs.getString("Nome");
                cb_tecnico.addItem(NomeProduto);               
            }

        } catch (Exception e) {
        }

    }
        
//<----------------------------------------------------------------------------------------------------------------------------------------->    

                public void Limpar(){
                                    
                tf_nome.setText("");
                tf_endereco.setText("");
                tf_numero.setText("");
                jf_telefone.setText("");
                tf_produto.setText("");
                tf_marcamodelo.setText("");
                tf_nserie.setText("");
                cb_acessorios.setSelectedItem("SIM");
                jt_acessorios.setText("");
                cb_tecnico.setSelectedItem("TÉCNICO");
                jf_entrada.setText("");
                jf_saida.setText("");
                cb_situacao.setSelectedItem("SITUAÇÃO ATUAL");
                cb_status.setSelectedItem("STATUS");
                jt_ordemservico.setText("");
                jt_processos.setText("");
                tf_pecas.setText("");
                tf_maodeobra.setText("");
                tf_total.setText("");
                tf_id.setText("");
                
                }
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tf_nome = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        tf_produto = new javax.swing.JTextField();
        tf_marcamodelo = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        tf_endereco = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        tf_numero = new javax.swing.JTextField();
        jf_telefone = new javax.swing.JFormattedTextField();
        jLabel5 = new javax.swing.JLabel();
        tf_nserie = new javax.swing.JTextField();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        cb_acessorios = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        cb_tecnico = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jf_entrada = new javax.swing.JFormattedTextField();
        jf_saida = new javax.swing.JFormattedTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        cb_situacao = new javax.swing.JComboBox();
        cb_status = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jt_acessorios = new javax.swing.JTextArea();
        jLabel14 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jt_ordemservico = new javax.swing.JTextArea();
        jScrollPane5 = new javax.swing.JScrollPane();
        jt_processos = new javax.swing.JTextArea();
        tf_pecas = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        tf_maodeobra = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        tf_total = new javax.swing.JTextField();
        tf_pesquisar = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        tf_id = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jt_os = new javax.swing.JTable();
        jSeparator1 = new javax.swing.JSeparator();
        jb_editar = new javax.swing.JButton();
        jb_limpar = new javax.swing.JButton();
        jb_fechar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jb_solicitar = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("AssisTec - Gerenciar O.S.");
        setResizable(false);
        getContentPane().setLayout(null);

        tf_nome.setEditable(false);
        tf_nome.setBackground(new java.awt.Color(255, 255, 255));
        tf_nome.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_nome.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_nome.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_nome);
        tf_nome.setBounds(10, 30, 240, 30);

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("NOME DO CLIENTE");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(10, 10, 130, 14);

        jLabel19.setBackground(new java.awt.Color(255, 255, 255));
        jLabel19.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel19.setForeground(new java.awt.Color(255, 255, 255));
        jLabel19.setText("PRODUTO");
        getContentPane().add(jLabel19);
        jLabel19.setBounds(10, 70, 60, 14);

        tf_produto.setEditable(false);
        tf_produto.setBackground(new java.awt.Color(255, 255, 255));
        tf_produto.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_produto.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_produto.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_produto);
        tf_produto.setBounds(10, 90, 190, 30);

        tf_marcamodelo.setEditable(false);
        tf_marcamodelo.setBackground(new java.awt.Color(255, 255, 255));
        tf_marcamodelo.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_marcamodelo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_marcamodelo.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_marcamodelo);
        tf_marcamodelo.setBounds(210, 90, 170, 30);

        jLabel20.setBackground(new java.awt.Color(255, 255, 255));
        jLabel20.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel20.setForeground(new java.awt.Color(255, 255, 255));
        jLabel20.setText("MARCA / MODELO");
        getContentPane().add(jLabel20);
        jLabel20.setBounds(210, 70, 140, 14);

        tf_endereco.setEditable(false);
        tf_endereco.setBackground(new java.awt.Color(255, 255, 255));
        tf_endereco.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_endereco.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_endereco.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_endereco);
        tf_endereco.setBounds(260, 30, 220, 30);

        jLabel3.setBackground(new java.awt.Color(255, 255, 255));
        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("ENDEREÇO");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(260, 10, 80, 14);

        jLabel17.setBackground(new java.awt.Color(255, 255, 255));
        jLabel17.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel17.setForeground(new java.awt.Color(255, 255, 255));
        jLabel17.setText("Nº");
        getContentPane().add(jLabel17);
        jLabel17.setBounds(490, 10, 50, 14);

        tf_numero.setEditable(false);
        tf_numero.setBackground(new java.awt.Color(255, 255, 255));
        tf_numero.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_numero.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_numero.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_numero);
        tf_numero.setBounds(490, 30, 50, 30);

        jf_telefone.setEditable(false);
        jf_telefone.setBackground(new java.awt.Color(255, 255, 255));
        jf_telefone.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_telefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_telefone.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_telefone.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_telefone);
        jf_telefone.setBounds(550, 30, 110, 30);

        jLabel5.setBackground(new java.awt.Color(255, 255, 255));
        jLabel5.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("TELEFONE");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(550, 10, 70, 14);

        tf_nserie.setEditable(false);
        tf_nserie.setBackground(new java.awt.Color(255, 255, 255));
        tf_nserie.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_nserie.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_nserie.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_nserie);
        tf_nserie.setBounds(390, 90, 180, 30);

        jLabel21.setBackground(new java.awt.Color(255, 255, 255));
        jLabel21.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel21.setForeground(new java.awt.Color(255, 255, 255));
        jLabel21.setText("Nº SÉRIE");
        getContentPane().add(jLabel21);
        jLabel21.setBounds(390, 70, 80, 14);

        jLabel22.setBackground(new java.awt.Color(255, 255, 255));
        jLabel22.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel22.setForeground(new java.awt.Color(255, 255, 255));
        jLabel22.setText("ACESSÓRIOS");
        getContentPane().add(jLabel22);
        jLabel22.setBounds(580, 70, 80, 14);

        cb_acessorios.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_acessorios.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SIM", "NÃO" }));
        cb_acessorios.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_acessorios.setEnabled(false);
        cb_acessorios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_acessoriosActionPerformed(evt);
            }
        });
        getContentPane().add(cb_acessorios);
        cb_acessorios.setBounds(580, 90, 80, 30);

        jLabel23.setBackground(new java.awt.Color(255, 255, 255));
        jLabel23.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel23.setForeground(new java.awt.Color(255, 255, 255));
        jLabel23.setText("ACESSÓRIOS QUE ACOMPANHA O PRODUTO");
        getContentPane().add(jLabel23);
        jLabel23.setBounds(670, 70, 300, 14);

        cb_tecnico.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_tecnico.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TÉCNICO" }));
        cb_tecnico.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_tecnico.setEnabled(false);
        getContentPane().add(cb_tecnico);
        cb_tecnico.setBounds(10, 150, 240, 30);

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("TÉCNICO RESPONSÁVEL");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(10, 130, 160, 14);

        jLabel15.setBackground(new java.awt.Color(255, 255, 255));
        jLabel15.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("ENTRADA");
        getContentPane().add(jLabel15);
        jLabel15.setBounds(260, 130, 80, 14);

        jf_entrada.setEditable(false);
        jf_entrada.setBackground(new java.awt.Color(255, 255, 255));
        jf_entrada.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_entrada.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_entrada.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_entrada.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_entrada);
        jf_entrada.setBounds(260, 150, 90, 30);

        jf_saida.setEditable(false);
        jf_saida.setBackground(new java.awt.Color(255, 255, 255));
        jf_saida.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        try {
            jf_saida.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jf_saida.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jf_saida.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(jf_saida);
        jf_saida.setBounds(360, 150, 90, 30);

        jLabel12.setBackground(new java.awt.Color(255, 255, 255));
        jLabel12.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("SAIDA");
        getContentPane().add(jLabel12);
        jLabel12.setBounds(360, 130, 90, 14);

        jLabel24.setBackground(new java.awt.Color(255, 255, 255));
        jLabel24.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel24.setForeground(new java.awt.Color(255, 255, 255));
        jLabel24.setText("SITUAÇÃO ATUAL");
        getContentPane().add(jLabel24);
        jLabel24.setBounds(460, 130, 180, 14);

        cb_situacao.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_situacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SITUAÇÃO ATUAL", "EM ESPERA", "CONCLUÍDO", "FALTA DE PEÇAS", "OBSERVAÇÃO" }));
        cb_situacao.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_situacao.setEnabled(false);
        getContentPane().add(cb_situacao);
        cb_situacao.setBounds(460, 150, 200, 30);

        cb_status.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        cb_status.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "STATUS", "ABERTO", "FECHADO" }));
        cb_status.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        cb_status.setEnabled(false);
        getContentPane().add(cb_status);
        cb_status.setBounds(730, 210, 120, 30);

        jLabel18.setBackground(new java.awt.Color(255, 255, 255));
        jLabel18.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel18.setForeground(new java.awt.Color(255, 255, 255));
        jLabel18.setText("STATUS O.S.");
        getContentPane().add(jLabel18);
        jLabel18.setBounds(730, 190, 90, 14);

        jScrollPane2.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));

        jt_acessorios.setEditable(false);
        jt_acessorios.setColumns(20);
        jt_acessorios.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jt_acessorios.setRows(5);
        jt_acessorios.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jt_acessorios.setSelectionColor(new java.awt.Color(0, 0, 0));
        jScrollPane2.setViewportView(jt_acessorios);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(670, 90, 310, 90);

        jLabel14.setBackground(new java.awt.Color(255, 255, 255));
        jLabel14.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel14.setForeground(new java.awt.Color(255, 255, 255));
        jLabel14.setText("PROCESSOS EXECUTADOS / OBSERVAÇÕES");
        getContentPane().add(jLabel14);
        jLabel14.setBounds(370, 190, 290, 14);

        jLabel7.setBackground(new java.awt.Color(255, 255, 255));
        jLabel7.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("ORDEM DE SERVIÇO");
        getContentPane().add(jLabel7);
        jLabel7.setBounds(10, 190, 130, 14);

        jScrollPane6.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));

        jt_ordemservico.setEditable(false);
        jt_ordemservico.setColumns(20);
        jt_ordemservico.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jt_ordemservico.setRows(5);
        jt_ordemservico.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jt_ordemservico.setSelectionColor(new java.awt.Color(0, 0, 0));
        jScrollPane6.setViewportView(jt_ordemservico);

        getContentPane().add(jScrollPane6);
        jScrollPane6.setBounds(10, 210, 350, 150);

        jScrollPane5.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));

        jt_processos.setEditable(false);
        jt_processos.setColumns(20);
        jt_processos.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jt_processos.setRows(5);
        jt_processos.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jt_processos.setSelectionColor(new java.awt.Color(0, 0, 0));
        jScrollPane5.setViewportView(jt_processos);

        getContentPane().add(jScrollPane5);
        jScrollPane5.setBounds(370, 210, 350, 150);

        tf_pecas.setEditable(false);
        tf_pecas.setBackground(new java.awt.Color(255, 255, 255));
        tf_pecas.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_pecas.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_pecas.setSelectionColor(new java.awt.Color(0, 0, 0));
        tf_pecas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tf_pecasActionPerformed(evt);
            }
        });
        getContentPane().add(tf_pecas);
        tf_pecas.setBounds(730, 270, 110, 30);

        jLabel25.setBackground(new java.awt.Color(255, 255, 255));
        jLabel25.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel25.setForeground(new java.awt.Color(255, 255, 255));
        jLabel25.setText("TOTAL R$ PEÇAS");
        getContentPane().add(jLabel25);
        jLabel25.setBounds(730, 250, 110, 14);

        jLabel26.setBackground(new java.awt.Color(255, 255, 255));
        jLabel26.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel26.setForeground(new java.awt.Color(255, 255, 255));
        jLabel26.setText("TOTAL R$ MÃO DE OBRA");
        getContentPane().add(jLabel26);
        jLabel26.setBounds(850, 250, 160, 14);

        tf_maodeobra.setEditable(false);
        tf_maodeobra.setBackground(new java.awt.Color(255, 255, 255));
        tf_maodeobra.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_maodeobra.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_maodeobra.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_maodeobra);
        tf_maodeobra.setBounds(850, 270, 110, 30);

        jLabel16.setBackground(new java.awt.Color(255, 255, 255));
        jLabel16.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel16.setForeground(new java.awt.Color(255, 255, 255));
        jLabel16.setText("TOTAL R$ O.S.");
        getContentPane().add(jLabel16);
        jLabel16.setBounds(730, 310, 100, 14);

        tf_total.setEditable(false);
        tf_total.setBackground(new java.awt.Color(255, 255, 255));
        tf_total.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_total.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_total);
        tf_total.setBounds(730, 330, 90, 30);

        tf_pesquisar.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_pesquisar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_pesquisar.setSelectionColor(new java.awt.Color(0, 0, 0));
        tf_pesquisar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tf_pesquisarKeyReleased(evt);
            }
        });
        getContentPane().add(tf_pesquisar);
        tf_pesquisar.setBounds(1010, 330, 260, 30);

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_lupa.png"))); // NOI18N
        getContentPane().add(jLabel6);
        jLabel6.setBounds(990, 330, 20, 30);

        jLabel8.setBackground(new java.awt.Color(255, 255, 255));
        jLabel8.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("PESQUISAR CLIENTE");
        getContentPane().add(jLabel8);
        jLabel8.setBounds(1010, 310, 200, 14);

        tf_id.setEditable(false);
        tf_id.setBackground(new java.awt.Color(255, 255, 255));
        tf_id.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        tf_id.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        tf_id.setSelectionColor(new java.awt.Color(0, 0, 0));
        getContentPane().add(tf_id);
        tf_id.setBounds(1060, 130, 50, 30);

        jLabel9.setBackground(new java.awt.Color(255, 255, 255));
        jLabel9.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("ID");
        getContentPane().add(jLabel9);
        jLabel9.setBounds(1060, 110, 30, 20);

        jLabel10.setBackground(new java.awt.Color(255, 255, 255));
        jLabel10.setForeground(new java.awt.Color(78, 78, 78));
        jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_executados.png"))); // NOI18N
        jLabel10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        getContentPane().add(jLabel10);
        jLabel10.setBounds(1120, 10, 150, 150);

        jLabel11.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("GERENCIAR O.S.");
        getContentPane().add(jLabel11);
        jLabel11.setBounds(1150, 170, 100, 14);

        jt_os.setAutoCreateRowSorter(true);
        jt_os.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jt_os.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jt_os.setSelectionBackground(new java.awt.Color(0, 0, 0));
        jt_os.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jt_osMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jt_os);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(0, 370, 1280, 170);

        jSeparator1.setForeground(new java.awt.Color(255, 255, 255));
        getContentPane().add(jSeparator1);
        jSeparator1.setBounds(70, 560, 1210, 10);

        jb_editar.setBackground(new java.awt.Color(255, 255, 255));
        jb_editar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_editar.png"))); // NOI18N
        jb_editar.setText("EDITAR");
        jb_editar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_editar.setBorderPainted(false);
        jb_editar.setEnabled(false);
        jb_editar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_editarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_editar);
        jb_editar.setBounds(970, 570, 100, 50);

        jb_limpar.setBackground(new java.awt.Color(255, 255, 255));
        jb_limpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_limpar.png"))); // NOI18N
        jb_limpar.setText("LIMPAR");
        jb_limpar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_limpar.setBorderPainted(false);
        jb_limpar.setEnabled(false);
        jb_limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_limparActionPerformed(evt);
            }
        });
        getContentPane().add(jb_limpar);
        jb_limpar.setBounds(1070, 570, 100, 50);

        jb_fechar.setBackground(new java.awt.Color(255, 255, 255));
        jb_fechar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fechar.png"))); // NOI18N
        jb_fechar.setText("FECHAR");
        jb_fechar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(78, 78, 78)));
        jb_fechar.setBorderPainted(false);
        jb_fechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_fecharActionPerformed(evt);
            }
        });
        getContentPane().add(jb_fechar);
        jb_fechar.setBounds(1170, 570, 100, 50);

        jButton1.setBackground(new java.awt.Color(255, 255, 255));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_atualizar.png"))); // NOI18N
        jButton1.setText("ATUALIZAR");
        jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jButton1.setBorderPainted(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(10, 570, 100, 50);

        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("AssisTec");
        getContentPane().add(jLabel13);
        jLabel13.setBounds(10, 550, 60, 14);

        jb_solicitar.setBackground(new java.awt.Color(255, 255, 255));
        jb_solicitar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_solicitar.png"))); // NOI18N
        jb_solicitar.setText("SOLICITAR");
        jb_solicitar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
        jb_solicitar.setBorderPainted(false);
        jb_solicitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jb_solicitarActionPerformed(evt);
            }
        });
        getContentPane().add(jb_solicitar);
        jb_solicitar.setBounds(570, 570, 120, 50);

        jLabel27.setBackground(new java.awt.Color(255, 255, 255));
        jLabel27.setForeground(new java.awt.Color(255, 255, 255));
        jLabel27.setText("TABELA DE O.S.");
        getContentPane().add(jLabel27);
        jLabel27.setBounds(570, 540, 150, 20);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/assistec_fundo2.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 1280, 650);

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void cb_acessoriosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_acessoriosActionPerformed
        try {
            if(cb_acessorios.getSelectedItem() == "NÃO"){
                jt_acessorios.setEditable(false);
            }
            else{
                jt_acessorios.setEditable(true);
            }
        } catch (Exception e) {
        }
    }//GEN-LAST:event_cb_acessoriosActionPerformed

    private void tf_pecasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_pecasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tf_pecasActionPerformed

    private void tf_pesquisarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tf_pesquisarKeyReleased
        pesquisarCliente();
    }//GEN-LAST:event_tf_pesquisarKeyReleased

    private void jt_osMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jt_osMouseClicked
        try {
            mostraItens();
            jb_editar.setEnabled(true);
            jb_limpar.setEnabled(true);

            tf_nome.setEditable(false);
            tf_endereco.setEditable(false);
            tf_numero.setEditable(false);
            jf_telefone.setEditable(false);
            tf_produto.setEditable(false);
            tf_marcamodelo.setEditable(false);
            tf_nserie.setEditable(false);
            jt_acessorios.setEditable(false);
            jf_entrada.setEditable(false);
            jf_saida.setEditable(false);
            jt_ordemservico.setEditable(false);
            jt_processos.setEditable(true);
            tf_pecas.setEditable(true);
            tf_maodeobra.setEditable(true);
            tf_total.setEditable(true);
            cb_acessorios.setEnabled(false);
            cb_tecnico.setEnabled(false);
            cb_situacao.setEnabled(true);
            cb_status.setEnabled(false);

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Tela_GerOS.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jt_osMouseClicked

    private void jb_editarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_editarActionPerformed
        editarOS();
    }//GEN-LAST:event_jb_editarActionPerformed

    private void jb_limparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_limparActionPerformed
        Limpar();
    }//GEN-LAST:event_jb_limparActionPerformed

    private void jb_fecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_fecharActionPerformed
        dispose();
    }//GEN-LAST:event_jb_fecharActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        listarOS();
        jb_editar.setEnabled(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jb_solicitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jb_solicitarActionPerformed
        Tela_RegSolicitacao trs = null;
        try {
            trs = new Tela_RegSolicitacao();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Tela_OrcamentoBasico.class.getName()).log(Level.SEVERE, null, ex);
        }
        trs.setVisible(true);
    }//GEN-LAST:event_jb_solicitarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Tela_GerOSTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Tela_GerOSTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Tela_GerOSTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Tela_GerOSTecnico.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new Tela_GerOSTecnico().setVisible(true);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(Tela_GerOSTecnico.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cb_acessorios;
    private javax.swing.JComboBox cb_situacao;
    private javax.swing.JComboBox cb_status;
    private javax.swing.JComboBox cb_tecnico;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton jb_editar;
    private javax.swing.JButton jb_fechar;
    private javax.swing.JButton jb_limpar;
    private javax.swing.JButton jb_solicitar;
    private javax.swing.JFormattedTextField jf_entrada;
    private javax.swing.JFormattedTextField jf_saida;
    private javax.swing.JFormattedTextField jf_telefone;
    private javax.swing.JTextArea jt_acessorios;
    private javax.swing.JTextArea jt_ordemservico;
    private javax.swing.JTable jt_os;
    private javax.swing.JTextArea jt_processos;
    private javax.swing.JTextField tf_endereco;
    private javax.swing.JTextField tf_id;
    private javax.swing.JTextField tf_maodeobra;
    private javax.swing.JTextField tf_marcamodelo;
    private javax.swing.JTextField tf_nome;
    private javax.swing.JTextField tf_nserie;
    private javax.swing.JTextField tf_numero;
    private javax.swing.JTextField tf_pecas;
    private javax.swing.JTextField tf_pesquisar;
    private javax.swing.JTextField tf_produto;
    private javax.swing.JTextField tf_total;
    // End of variables declaration//GEN-END:variables
}
